package jk.fox.exchange.server;

import jk.fox.common.payload.message.MessageDispatcher;
import jk.fox.config.exchange.standard.DefaultExchangeConfiguration;
import jk.fox.exchange.Exchange;
import jk.fox.exchange.server.handler.ExchangeHandler;
import jk.fox.exchange.client.ClientExchange;
import jk.fox.exchange.client.DefaultClientExchange;
import jk.fox.transport.ClientTransporter;
import jk.fox.transport.ServerTransporter;

/**
 * @author cuichao
 * @Description: DefaultExchange
 * @Date: create in 2020/6/4 0:08
 */
public class DefaultExchange implements Exchange {

    private DefaultExchangeConfiguration config;
    private MessageDispatcher messageDispatcher;

    public DefaultExchange(DefaultExchangeConfiguration config, MessageDispatcher messageDispatcher) {
        this.config = config;
        this.messageDispatcher = messageDispatcher;
    }

    @Override
    public ClientExchange client(ClientTransporter transporter) {
        return new DefaultClientExchange(config,transporter);
    }

    @Override
    public ServerExchange server(ServerTransporter transporter, ExchangeHandler exchangeHandler) {
        return new DefaultServerExchange(config,exchangeHandler,transporter);
    }
}
